package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.entity.Employee;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 获取所有员工数据
     * @param name
     * @return
     */
    Page<Employee> selectAll(String name);

    /**
     * 插入员工数据
     * @param employee
     */
    void insert(Employee employee);

    /**
     * 根据id查询员工
     * @param id
     * @return
     */
    @Select("select * from employee where id = #{id}")
    Employee findById(Long id);

    /**
     * 更新员工数据
     * @param employee
     */
    void update(Employee employee);

    /**
     * 根据员工id修改员工状态
     * @param id
     * @param status
     */
    void updateStatusByEmployeeId(Long id, Integer status);

    /**
     * 根据员工id查询员工密码
     * @param empId
     * @return
     */
    @Select("select password from employee where id = #{empId}")
    String selectPasswordByEmployeeId(Long empId);

    /**
     * 根据员工id修改员工密码
     * @param empId
     * @param s
     * @return
     */
    @Update("update employee set password = #{newPassword} where id = #{empId}")
    void updatePasswordByEmployeeId(Long empId, String newPassword);
}
